﻿<UserControl x:Class="redditMetro.CollectionPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:local="using:redditMetro.Controls"
    xmlns:coll="using:redditMetro.Collections"
    xmlns:app="using:redditMetro"
    Loaded="Page_Loaded" Unloaded="Page_Unloaded"
    mc:Ignorable="d"
    d:DesignHeight="768" d:DesignWidth="1366">

    <UserControl.Resources>
    </UserControl.Resources>

    <!-- Page Content -->

    <Grid x:Name="LayoutRoot" Style="{StaticResource LayoutRootGridStyle}" PointerPressed="Grid_PointerPressed">
        <VisualStateManager.VisualStateGroups>
            <VisualStateGroup x:Name="OrientationStates">
                <VisualState x:Name="Full"/>
                <VisualState x:Name="Fill"/>
                <VisualState x:Name="Portrait">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ItemGridView" Storyboard.TargetProperty="Visibility" >
                            <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ItemListView" Storyboard.TargetProperty="Visibility" >
                            <DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
                <VisualState x:Name="Snapped">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Style" Storyboard.TargetName="BackButton">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource SnapBackButtonStyle}"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Style" Storyboard.TargetName="PageTitle">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource SnapPageTitleStyle}"/>
                        </ObjectAnimationUsingKeyFrames>

                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="ItemTemplate" Storyboard.TargetName="ItemListView">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource SnapListItemTemplate}"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="ItemsPanel" Storyboard.TargetName="ItemListView">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource SnapListItemsPanelTemplate}"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ItemGridView" Storyboard.TargetProperty="Visibility" >
                            <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ItemListView" Storyboard.TargetProperty="Visibility" >
                            <DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>

        <Grid.RowDefinitions>
            <RowDefinition Height="140"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>
            <Button x:Name="BackButton" Style="{StaticResource BackButtonStyle}"/>
            <TextBlock x:Name="PageTitle" Text="{StaticResource AppName}" Style="{StaticResource PageTitleStyle}" Grid.Column="1" />
        </Grid>

        <GridView x:Name="ItemGridView" ItemTemplate="{StaticResource GroupedItemTemplate}" ItemContainerStyle="{StaticResource GridTileStyle}" ItemsPanel="{StaticResource GridItemsPanelTemplate}"
              Grid.Row="1" Background="{StaticResource PageBackgroundBrush}" BorderThickness="0" VerticalAlignment="Stretch" ScrollViewer.HorizontalScrollMode="Enabled" ScrollViewer.HorizontalScrollBarVisibility="Auto" IncrementalLoadingThreshold="25" PreferIncrementalLoading="True"
              SelectionChanged="ItemView_SelectionChanged" />
        <ListView x:Name="ItemListView" ItemTemplate="{StaticResource PortraitListItemTemplate}" ItemContainerStyle="{StaticResource ListTileStyle}"  ItemsPanel="{StaticResource PortraitListItemsPanelTemplate}"
              Visibility="Collapsed" Grid.Row="1" Background="{StaticResource PageBackgroundBrush}" BorderThickness="0" VerticalAlignment="Stretch"
              SelectionChanged="ItemView_SelectionChanged"/>
        <ApplicationBar VerticalAlignment="Bottom" DismissMode="LightDismiss" Background="#9BBBDB" Grid.Row="1">
            <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="30,0,30,0">
                <StackPanel Orientation="Vertical" Margin="0,14,20,5">
                    <Button x:Name="btnSettings" Click="btnSettings_Click" FontFamily="Segoe UI Symbol" FontSize="25" HorizontalAlignment="Center" VerticalAlignment="Center" Padding="4,0,0,0" Style="{StaticResource HomeButtonStyle}" Content="&#xE0C2;" />
                    <TextBlock HorizontalAlignment="Center" FontFamily="Segoe UI" FontSize="14" Text="Settings" Foreground="White" />
                </StackPanel>
                <StackPanel Orientation="Vertical" Margin="0,14,20,5">
                    <Button x:Name="btnHome" IsEnabled="False" FontFamily="Segoe UI Symbol" FontSize="25" HorizontalAlignment="Center" VerticalAlignment="Center" Padding="4,0,0,0" Style="{StaticResource HomeButtonStyle}" Content="&#xE10F;" />
                    <TextBlock HorizontalAlignment="Center" FontFamily="Segoe UI" FontSize="14" Text="Home" Foreground="#7F8D8D8D" />
                </StackPanel>
            </StackPanel>
        </ApplicationBar>
        <local:AccountSettingsPanel x:Name="accountSettings" Grid.RowSpan="2" HorizontalAlignment="Right" Margin="0,0,-346,0">
            <local:AccountSettingsPanel.Transitions>
                <TransitionCollection>
                    <RepositionThemeTransition />
                </TransitionCollection>
            </local:AccountSettingsPanel.Transitions>
        </local:AccountSettingsPanel>
    </Grid>

</UserControl>
